package br.com.testeoab.listView;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import br.com.testeoab.R;
import br.com.testeoab.model.Perguntas;

public class ListViewPerguntas extends BaseAdapter{

	private Context context;
	private List<Perguntas> clsPerguntas = new ArrayList<Perguntas>();

	
	public ListViewPerguntas(Context context, List<Perguntas> clsPerguntas){
		this.context = context;
		this.clsPerguntas = clsPerguntas;

	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return clsPerguntas.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return clsPerguntas.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Perguntas clsPergunta = clsPerguntas.get(position);
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View v = inflater.inflate(R.layout.pergunta, null);
		
		TextView txtPergunta = (TextView) v.findViewById(R.id.txtPergunta);
		
		txtPergunta.setText(clsPergunta.getStrPergunta());
		
		return v;
	}
	public View getView(Perguntas clsPergunta) {
		
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View v = inflater.inflate(R.layout.pergunta, null);
		
		TextView txtPergunta = (TextView) v.findViewById(R.id.txtPergunta);
		
		txtPergunta.setText(clsPergunta.getStrPergunta());

		
		return v;
	}
}
